package cn.gson.fengboot.controller;

import cn.gson.fengboot.model.pojos.Zbarter;
import cn.gson.fengboot.model.pojos.Zbarterdetails;
import cn.gson.fengboot.model.pojos.Zcontractdetails;
import cn.gson.fengboot.model.service.ZbarterService;
import cn.gson.fengboot.model.service.ZcontractService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/huanhuo")
public class ZbarterController {
    @Autowired
    ZbarterService ddservice;

    //换货出框查询方法
    @RequestMapping("/list_hh")
    @ResponseBody
    public Map<String,Object> huanhuolist(Integer page, Integer size,String search,String search2){
        Page<Object> obj = PageHelper.startPage(page, size);
        ddservice.huanhuolist(search,search2);

        Map<String,Object> map = new HashMap<>();
        map.put("total",obj.getTotal());
        map.put("rows",obj.getResult());
        return map;
    }

    //换货弹框查询
    @RequestMapping("/hhtk")
    @ResponseBody
    public Map<String,Object> hhtk(Integer page, Integer size,String search,String search2){
        Page<Object> obj = PageHelper.startPage(page, size);
        ddservice.hhtk(search,search2);

        Map<String,Object> map = new HashMap<>();
        map.put("total",obj.getTotal());
        map.put("rows",obj.getResult());
        return map;
    }

    //订单换货单
    @RequestMapping("/dd_hhd")
    @ResponseBody
    public List<Zbarter> ddhhd(String search){

        return ddservice.ddhhd(search);
    }

    //更具换货单ID查询换货单
    @RequestMapping("/hhdcxhhd")
    @ResponseBody
    public Zbarter ddxqcx(String search){
        return ddservice.ddxqcx(search);
    }


    //换货单详情
    @RequestMapping("/hhdcp")
    @ResponseBody
    public List<Zbarterdetails> allpro(String search){

        return ddservice.allpro(search);
    }

    @RequestMapping("/add_hh")
    @ResponseBody
    public void addhuanhuo(@RequestBody Zbarter hh){
        ddservice.addhuanhuo(hh);
    }
}
